/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/powx-n
   @Language: C++
   @Datetime: 19-06-19 15:50
   */

class Solution {
public:
	double myPow(double x, int n) {
		double res=1.0;
		for(int i=n; i!=0; x*=x, i/=2)
			if(i&1) res *= x;
		return n>0?res:1/res;
	}
};
